<%--
  Created by IntelliJ IDEA.
  User: azure
  Date: 2021/11/5
  Time: 17:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">


    <title>星星制作者</title>

    <style>
        body {
            background: url("./img/bg1.jpg") no-repeat center top !important;
        }

        .register-box-body {
            background-color: rgba(0, 0, 0, .2) !important;
        }
    </style>


    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <!-- Font Awesome -->
    <!-- Ionicons -->
    <!-- Theme style -->
    <!-- iCheck -->
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <link rel="stylesheet" href="./plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="./plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="./plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="./plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="./plugins/iCheck/square/blue.css">
</head>

<body class="hold-transition register-page">
<div class="register-box">
    <div class="register-logo">


        <a href="#" style="color: #8c8c8c"><b>书籍</b>管理系统</a>


    </div>

    <div class="register-box-body">
        <p class="login-box-msg">新用户注册</p>

        <form action="${pageContext.request.contextPath}/user/register" method="post" id="form_login">
            <div class="form-group has-feedback">
                <input type="text" class="form-control" placeholder="请输入账户" name="userAccount" autocomplete="false">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="email" class="form-control" placeholder="Email" name="email" autocomplete="false">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" class="form-control" placeholder="密码" name="password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" class="form-control" placeholder="确认密码" id="regist_password">
                <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
            </div>
            <div class="row">

                <!-- /.col -->
                <div class="col-xs-4" style="margin-left: 120px;">
                    <button type="submit" class="btn btn-primary btn-block btn-flat">注册</button>
                </div>
                <!-- /.col -->
            </div>
        </form>


        <a href="${pageContext.request.contextPath}/login.jsp" class="text-center"
           style="display:block;margin-top: 20px;">我有账号，现在就去登录</a>
    </div>
    <!-- /.form-box -->
</div>
<div style="width: 100px;height: 200px;margin: 50px auto;color: #747474">技术支持：卫鹏</div>

<!-- /.register-box -->

<!-- jQuery 2.2.3 -->
<!-- Bootstrap 3.3.6 -->
<!-- iCheck -->
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' // optional
        });
    });


    //入口函数:
    $(function () {
        //获取账户的值:
        var user_account = $("input[name='userAccount']").val();
        //获取email的值:
        var email = $("input[name='email']").val();
        //获取密码的值:
        var password = $("input[name='password']").val();
        //获取确认密码的值：
        var regist_password = $("input[name='regist_password']").val();

        /**
         * @return {boolean}
         */
        function SubmitCk() {
            var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
            if (!reg.test(email.val())) {
                alert("请输入正确邮箱地址");
                return false;
            }
            return true;
        }

        function accountCK() {
            //账户最少3位数字:
            var flag = /^\d{3,}$/;
            if (flag.test(user_account)) {
                alert("请输入至少3为数字！");
                return false;
            }
            return true;
        }

        function passwordCK() {
            if (password != null && regist_password != null) {
                return true;
            }
            return password === regist_password;
        }

        /*
            失去焦点时,执行方法:
         */
        //获取表单:
        $("#form_login").submit(function () {
            var flag = SubmitCk && accountCK && passwordCK;
            if (flag) {
                location.href = ${pageContext.request.contextPath}"/user/register";
            } else {
                alert("表单提交有误，请重新输入！");
            }
        });


    })
</script>

</body>

</html>
